package com.mayuanfei.controller;

import com.aizuda.snailjob.server.model.dto.CallbackParamsDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * TODO 类描述
 *
 * @author 老马
 * @date 2025-03-28 17:29
 */
@Slf4j
@RestController
@RequestMapping("/workflow")
public class WorkflowCallbackController {

    @PostMapping("/callback")
    public void callback(@RequestBody CallbackParamsDTO callbackParams, @RequestHeader HttpHeaders headers) {
        // callbackParams 对象可以获取到当前回调通知之前的上下文内容
        // secret 是当回调通知的秘钥，用于鉴权
        String secret = headers.getFirst("secret");
        log.info("callback: {}, secret:{}", callbackParams, secret);
        log.info("完成任务推送到监控");
    }
}